#include "commond.hpp"
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
const std::string path = "./temp/mypipe";

int main()
{
    createPipe(path);
    std::cout << "open start" << std::endl;
    int rfd = open(path.c_str(), O_RDONLY);
    std::cout << "open end" << std::endl;
    if(rfd == -1)
    {
        std::cout << "open fail" << std::endl;
        _exit(1);
    }
    char buffer[1024];
    while(1)
    {
        ssize_t num = read(rfd, buffer, sizeof(buffer) - 1);
        buffer[num] = 0;
        std::cout << buffer << std::endl;
    }

    delPipe(path);
    return 0;
}